<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div class="box">
        <p>{{n}}</p>
        <p v-big="n"></p>
        <button @click="n++">点击加一</button><br>
        <input type="text" v-big="n" :value="n">
    </div>
    <script>
        new Vue({
            el: '.box',
            data: {
                n: 1,
            },
            directives: {
                // big(el, binding) {
                //     // 对指令所在元素的值扩大十倍
                //     el.innerText = binding.value * 10
                //     el.focus()
                // }
                big: {
                    bind(el, binding) {
                        console.log(111);

                        el.innerText = binding.value * 10
                        el.focus()
                    },
                    inserted(el, binding) {
                        console.log(222);
                        el.innerText = binding.value * 10
                        el.focus()
                    },
                    update(el, binding) {
                        console.log(333);
                        el.innerText = binding.value * 10
                        el.focus()
                    }
                }
            }
        })
    </script>
</body>

</html>